/*
 * 发布订阅模式
 */
package com.ck.dp.observer;

import com.ck.dp.subject.WeatherData;
/**
 * 
 * @Description 显示当前天气的公告牌
 * @author admin
 * @time 2017年10月18日下午1:26:15
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {
	
    private WeatherData weatherData;

    private float temperature;//温度
    private float humidity;//湿度
    private float pressure;//气压
	
	
    
	public CurrentConditionsDisplay() {
		 this.weatherData = weatherData;
	     this.weatherData.registerObserver(this);
	}

	public void display() {
		System.out.println("当前温度为：" + this.temperature + "℃");
        System.out.println("当前湿度为：" + this.humidity);
        System.out.println("当前气压为：" + this.pressure);

	}

	public void update() {
		this.temperature = this.weatherData.getTemperature();
        this.humidity = this.weatherData.getHumidity();
        this.pressure = this.weatherData.getPressure();
        display();
	}

}
